<template>
	<view class="shop_register">
		<view class="register_main">
			<view class="main_icon">
				<image src="../../static/img/logo2.png" mode=""></image> register
			</view>
			<view class="main_con">
				<u--input class="acc" border="bottom" clearable placeholder="请输入昵称" v-model="uname"></u--input>
				<u--input class="acc" type="number" border="bottom" clearable placeholder="请输入账号"
					v-model="acc"></u--input>
				<u--input class="pwd" type="password" placeholder="请输入密码" border="bottom" v-model="pwd"></u--input>
				<u-button type="primary" @click="userBtn" color="#ffa6a6" class="register_btn" text="注册"></u-button>
				<u-button type="primary" @click="jumpLog" class="login_btn" color="#ff78a2" text="登录"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				acc: "",
				pwd: "",
				uname: ""
			};
		},
		methods: {
			rightClick() {
				console.log('rightClick');
			},
			leftClick() {
				console.log('leftClick');
			},
			jumpLog() {
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
			async userBtn() {
				let uname = this.uname
				let acc = this.acc
				let pwd = this.pwd
				if (uname == "" || acc == "" || pwd == "") {
					uni.showToast({
						title: "信息不能为空",
						icon: 'none'
					})
				} else {
					uni.showLoading({
						title: "用户注册中..."
					})
					uniCloud.callFunction({
						name: "user_register",
						data: {
							uname,
							acc,
							pwd
						}
					}).then(res => {
						// console.log(res)
						let {
							result: {
								msg,
								code
							}
						} = res
						console.log(msg, code)
						uni.showToast({
							title: msg,
							icon: "none"
						})
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.shop_register {
		height: 100vh;
		position: relative;

	}

	.register_main {

		.main_icon {
			padding-top: 100px;
			font-size: 48px;
			font-weight: 700;
			text-align: center;
			color: #ffa6a6;
			display: flex;
			align-items: center;
			justify-content: center;

			image {
				width: 50px;
				height: 50px;
				margin-right: 10px;
			}
		}

		.main_con {
			margin: 40px;
		}

		.acc {
			margin-bottom: 20px;
		}

		.pwd {
			margin-bottom: 40px;
		}

		.register_btn {
			margin-bottom: 10px;
			border-radius: 20px;
		}

		.login_btn {
			border-radius: 20px;
		}
	}
</style>